<?php
namespace App\Repositories;

use App\Model\MaterialFlow;
use App\Traits\SingletonTrait;
use Hyperf\DbConnection\Db;

class MaterialFlowRepository extends AbstractRepository
{
    use SingletonTrait;

    public function model()
    {
        return 'App\\Model\\MaterialFlow';
    }

    public function getFromData($flow){
        $return =[];
        switch ($flow->from_data_type){
            case 0:
                $return['name'] = '文明办';
                break;
            case MaterialFlow::FROM_DATA_TYPE_ONE:
                $result = AreaRepository::getInstance()->getById($flow->from_data_id);
                $return['name'] = $result->name;
                break;
            case MaterialFlow::FROM_DATA_TYPE_TWO:
                $result = StreetRepository::getInstance()->getById($flow->from_data_id);
                $return['name'] = $result->name;
                break;
            case MaterialFlow::FROM_DATA_TYPE_THREE:
                $result = CommunityRepository::getInstance()->getById($flow->from_data_id);
                $return['name'] = $result->name;
                break;
        }
        return $return;
    }
}